<!-- THE MAIN CONTENT CLASS-->

<script>
  $(document).ready(function(){
    $('#news-pagination ul li a').each(function(){
      var tmp = $(this).attr('href');
      $(this).attr('href', tmp+'#tabs-2');
    });

    $('#articles-pagination ul li a').each(function(){
      var tmp = $(this).attr('href');
      $(this).attr('href', tmp+'#tabs-3');
    });

    $('#webinars-pagination ul li a').each(function(){
      var tmp = $(this).attr('href');
      $(this).attr('href', tmp+'#tabs-4');
    });

    $('#download-pagination ul li a').each(function(){
      var tmp = $(this).attr('href');
      $(this).attr('href', tmp+'#tabs-5');
    });
  });
</script>

<script>
  $(document).ready(function(){
    $(".album").hover(function(){
      $(this).find("a:first-child").css('top', -$(this).find('a:last-child img').height()+10);
      $(this).find("a:first-child").css('left', $(this).find('a:last-child img').width()-15);
      $(this).find("a:first-child").toggle();
    });
  });
</script>

<div class='spacer'>&nbsp;</div>
<div id="tabs">
<ul>
	<li><a href="#tabs-1">Profile</a></li>
	<li><a href="#tabs-2">News & Content</a></li>
	<li><a href="#tabs-3">Journal</a></li>
	<li><a href="#tabs-4">Webinars</a></li>
	<li><a href="#tabs-5">Download Links</a></li>
</ul>

<span class="search-member">
    <form method="POST" action="<?php echo bu("search/members"); ?>">
      <input type="text" name="member" value="Search Members.." onClick="this.value= '';" />
    </form>
</span>

<div id="tabs-1" class='mainContainer member'>
  <span><?php echo $this->renderPartial('/partials/_notifications'); ?></span>

	<div style="padding-right:20px;">
    <?php if(isset($profile_picture)){ ?>
      <img src='<?php echo bu("assets/users/".$user->id."/".$profile_picture->content); ?>' alt='Profile Picture' style="width:150px;" />
    <?php }else{ ?>
      <img src='<?php echo bu("assets/users/anonymous.jpg"); ?>' alt='Profile Picture' style="width:150px;" />
    <?php } ?>
		<div class='spacer'>&nbsp;</div>
	</div>
	<div id="album">
    <form id="form" class="form" novalidate="true" action="<?php echo bu('photos/create'); ?>" method="POST" enctype="multipart/form-data">
      Upload new photo
      <?php echo CHtml::activeFileField($model, 'upload', array('required' => 'required')); ?>
      <input type="submit" value="Upload" />
    </form>
    <br /><br /><br />

    <?php if(count($photos) > 0){ ?>
		<label>Or take from your album:</label><br /><br />

      <?php foreach($photos as $foto){ ?>
        <span class="album" style="position:relative;">
          <a style="z-index:100; display:none; position:absolute; left:0px; top:0px;" href="<?php echo bu("photos/destroy?id=".$foto->id); ?>"><img src="<?php echo bu("images/icons/delete-icon.png"); ?>" width="20px" /></a>
          <a href="<?php echo bu("photos/update?id=".$foto->id); ?>"><img src='<?php echo bu("assets/users/".$_SESSION['id'].'/'.$foto->content); ?>' alt='Picture' style="height:75px; margin-right:5px;" /></a>
        </span>
      <?php } ?>

    <?php } ?>

    <br />
		<a class='normal' href='<?php echo bu("members/"); ?>'><input type='button' value='Back to Profile' /></a>
	</div>
</div>

<div id="tabs-2" class='tabs'>
    <a style="float:right; margin-right:10px;" href="<?php echo bu('news/rss/'.$_SESSION['member_id']); ?>"><img src="<?php echo bu('images/icons/rss.png'); ?>" style="width:20px;" /></a>
    <h3>News</h3><hr />
    <?php if($news){ ?>
      <?php foreach($news as $n){ ?>
      <div class='news'> <!-- Format the news view -->
        <div><a href='<?php echo bu("news/view/".$n->id); ?>'><img width="100px" src= '<?php echo bu("assets/news/".$n->image) ?>' align='left' /></a></div>
        <div>
          <h3><a href='<?php echo bu("news/view/".$n->id); ?>'><?php echo $n->subject; ?></a></h3>
          <div class='date'><?php echo Helpers::customDate($n->created_at); ?></div>
          <p><?php echo substr($n->content,0,540); ?></p>
        </div>
      </div>
      <?php } ?>
      <p style="float:right;"><a href="<?php echo bu("news?member=".$_SESSION['member_id']); ?>">Browse all news..</a></p>
    <?php }else{echo '<i>No contents yet.</i>';} ?>
    <br /><br />

    <a style="float:right; margin-right:10px;" href="<?php echo bu('articles/rss/'.$_SESSION['member_id']); ?>"><img src="<?php echo bu('images/icons/rss.png'); ?>" style="width:20px;" /></a>
    <h3>Articles</h3><hr />
    <?php if($articles){ ?>
      <?php foreach($articles as $article){ ?>
      <div class='news'> <!-- Format the news view -->
        <div><a href='<?php echo bu("articles/view/".$article->id); ?>'><img width="100px" src= '<?php echo bu("assets/articles/".$article->image) ?>' align='left' /></a></div>
        <div>
          <h3><a href='<?php echo bu("articles/view/".$article->id); ?>'><?php echo $article->subject; ?></a></h3>
          <div class='date'><?php echo Helpers::customDate($article->created_at); ?></div>
          <p><?php echo substr($article->content,0,540); ?></p>
        </div>
      </div>
      <?php } ?>
      <p style="float:right;"><a href="<?php echo bu("articles?member=".$_SESSION['member_id']); ?>">Browse all articles..</a></p>
    <?php }else{echo '<i>No contents yet.</i>';} ?>
    <br /><br />

    <a style="float:right; margin-right:10px;" href="<?php echo bu('links/rss/'.$_SESSION['member_id']); ?>"><img src="<?php echo bu('images/icons/rss.png'); ?>" style="width:20px;" /></a>
    <h3>Links</h3><hr />
    <?php if($links){ ?>
      <?php foreach($links as $link){ ?>
      <div class='news'> <!-- Format the news view -->
        <div>
          <h3><a href='<?php echo bu("links/view/".$link->id); ?>'><?php echo $link->title; ?></a></h3>
          <div class='date'><?php echo Helpers::customDate($link->created_at); ?></div>
          <p><?php echo substr($link->description,0,540); ?></p>
        </div>
      </div>
      <?php } ?>
      <p style="float:right;"><a href="<?php echo bu("links?member=".$_SESSION['member_id']); ?>">Browse all Links..</a></p>
    <?php }else{echo '<i>No contents yet.</i>';} ?>

</div>

<div id="tabs-3" class='tabs'>
  <?php if($journals){ ?>
    <?php foreach($journals as $journal){ ?>
    <div class='news'> <!-- Format the news view -->
      <div>
        <h3><a href='<?php echo bu("journals/download?id=".$journal->id); ?>'><?php echo $journal->title; ?></a></h3>
        <div class='date'><?php echo Helpers::customDate($journal->created_at); ?></div>
        <p><?php echo substr($journal->description,0,540); ?></p>
      </div>
    </div>
    <?php } ?>

    <div class='spacer'>&nbsp;</div><div class='spacer'>&nbsp;</div>
    <div id="articles-pagination" class="pagination">
      <?php
        $this->widget('CLinkPager',array(
          'pages'=>$journals_pages,
          "cssFile" => false,
          "header" => "",
        ));
      ?>
    </div>
  <?php }else{echo '<i>No contents yet.</i>';} ?>
</div>


<div id="tabs-4" class='tabs'>

  <?php if($webinars){ ?>
    <?php foreach($webinars as $webinar){ ?>
    <div class='news'> <!-- Format the news view -->
      <div>
        <h3><a href='<?php echo bu("webinar/view/".$webinar->id); ?>'><?php echo $webinar->subject; ?></a></h3>
        <div class='date'><?php echo Helpers::customDate($webinar->created_at); ?></div>
        <p><?php echo substr($webinar->content,0,540); ?></p>
      </div>
    </div>
    <?php } ?>

    <div class='spacer'>&nbsp;</div><div class='spacer'>&nbsp;</div>
    <div id="webinars-pagination" class="pagination">
      <?php
        $this->widget('CLinkPager',array(
          'pages'=>$webinars_pages,
          "cssFile" => false,
          "header" => "",
        ));
      ?>
    </div>
  <?php }else{echo '<i>No contents yet.</i>';} ?>
</div>


<div id="tabs-5" class='tabs'>
  <?php if($downloadUrls){ ?>
    <?php foreach($downloadUrls as $downloadUrl){ ?>
    <div class='news'> <!-- Format the news view -->
      <div>
        <h3><a href='<?php echo bu("downloadUrl/view/".$downloadUrl->id); ?>'><?php echo $downloadUrl->title; ?></a></h3>
        <div class='date'><?php echo Helpers::customDate($downloadUrl->created_at); ?></div>
        <p><?php echo substr($downloadUrl->description,0,540); ?></p>
      </div>
    </div>
    <?php } ?>

    <div class='spacer'>&nbsp;</div><div class='spacer'>&nbsp;</div>
    <div id="download-pagination" class="pagination">
      <?php
        $this->widget('CLinkPager',array(
          'pages'=>$downloadUrls_pages,
          "cssFile" => false,
          "header" => "",
        ));
      ?>
    </div>
  <?php }else{echo '<i>No contents yet.</i>';} ?>
</div>

</div>